<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<link type="text/css" rel="stylesheet"
	href="static/bootstrap/css/bootstrap.min.css" />
</head>
<body>
	<script type="text/javascript"
		src="static/bootstrap/js/jquery-3.4.1.min.js"></script>
	<script type="text/javascript"
		src="static/bootstrap/js/bootstrap.min.js"></script>
		<script type="text/javascript">
		$(function(){
			$("#del").click(function(){
				var str="";
				var cc=$(":checkbox:checked");
				if(cc.length==0){
					alert("至少选中一行");
					return false;
				}
				 $(":checkbox:checked").each(function(){
					str+=$(this).val()+",";
				}); 
				/* for(var i=0;i<cc.length;i++){
					str +=cc[i].value+",";} */
				var param={
			    		action:'deleteAll',
			    		ids:str
				};
			    $.get("user",param,function(data){
			    	console.log(data,res);
			    },'json');
			    return false;
			});
			$("#delall").click(function(){
				//获得当前页中多选框的value值，即id的值
				var str="";
				var ck=$(":checkbox");
				for(var i=0;i<ck.length;i++){
					str +=ck[i].value+",";}
			    var param={
			    		action:'deleteAll',
			    		ids:str
			    };
			    $.get("user",param,function(data){
			    	console.log(data,res);
			    },'json');
			    return false;
			});
		})
		</script>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<span class="glyphicon glyphicon-trash"><a id="delall" href="user?action=deleteAll">全部删除</a></span> 
				<span class="glyphicon glyphicon-remove"><a id="del" href="user?action=deleteAll">选中删除</a></span> 
				<span class="glyphicon glyphicon-plus" class="btn btn-primary btn-lg"
				data-toggle="modal" data-target="#myModal"><a href="#">新增</a></span> 
				
			</div>
		</div>
		<div class="row">
			<table class="table table-hover">
				<tr>
				    <td></td>
					<td>用户名</td>
					<td>邮箱</td>
					<td>性别</td>
					<td>状态码</td>
					<td>角色</td>
					<td>激活状态</td>
					<td>操作</td>
				</tr>
				<c:forEach items="${list}" var="user">
					<tr>
					<td><input type="checkbox" name="ids" value="${user.uid}"></input></td>
						<td>${user.uname}</td>
						<td>${user.uemail}</td>
						<td>${user.ugender}</td>
						<td>${user.uflag}</td>
						<td>${user.urole}</td>
						<td>${user.ucode}</td>
						<td><a href="user?action=selectOne&id=${user.uid}">修改</a></td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="8" align="center">
						<nav aria-label="Page navigation">
							<ul class="pagination">
								<li><a
									href="user?action=show&page=${pb.page-1<1?1:(pb.page-1)}"
									aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
								</a></li>
								<li><a href="#">第${pb.page}页</a></li>
								<li><a href="#">共${pb.pageNum}页</a></li>
								<li><a href="#">每页显示${pb.rowsPerPage}条数据</a></li>
								<li><a href="#">共${pb.rowsNum}条数据</a></li>
								<li><a href="user?action=show&page=${pb.pageNum}">末页</a></li>
								<li><a href="user?action=show&page=${pb.page+1}"
									aria-label="Next"> <span aria-hidden="true">&raquo;</span>
								</a></li>
							</ul>
						</nav>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<form action="user">
			<input type="hidden" name="action" value="userAdd">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">新增用户</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="username">用户名:</label> <input type="text"
								class="form-control" name="username" placeholder="6-20个字母或数字组成的用户名">
						</div>
						<div class="form-group">
							<label for="userpass">密码:</label> <input type="password"
								class="form-control" name="userpass" placeholder="6位数字组成">
						</div>
						<div class="form-group">
							<label for="userpass2">重复密码:</label> <input type="password"
								class="form-control" name="userpass2" placeholder="与原密码一致">
						</div>
						<div class="form-group">
							<label for="exampleInputEmail1">邮箱地址:</label> <input type="email"
								class="form-control" name="useremail" placeholder="按邮箱格式填写">
						</div>
						<div class="form-group">
							<label class="control-label" for="usersex">性别：</label><input
								type="radio" class="form-control" name="usersexy" value="男">男
							<input type="radio" class="form-control" name="usersexy" value="女">女
						</div>
						<div class="form-group">
							<label for="exampleInputEmail1">状态:</label> <input type="text"
								class="form-control" name="flag" placeholder="1为存在，0为不存在">
						</div>
						<div class="form-group">
							<label for="exampleInputEmail1">角色:</label> <input type="text"
								class="form-control" name="role" placeholder="1为用户，0为管理员">
						</div>
						<div class="form-group">
							<label for="exampleInputEmail1">激活码:</label> <input type="text"
								class="form-control" name="code" placeholder="1为激活，0为未激活">
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary">确认添加</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>